/**
 * 
 */
package com.effectiv.gooruda.rest.api.operation;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import com.effectiv.gooruda.rest.api.domain.FileStorage;
import com.effectiv.gooruda.rest.docs.core.annotation.Api;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiHeader;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiHeaders;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiMethod;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiParam;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiRequestParam;
import com.effectiv.gooruda.rest.docs.core.annotation.ApiResponseObject;
import com.effectiv.gooruda.rest.docs.core.pojo.ApiVerb;

/**
 * @author Dhrubo
 *
 */
@Api(name = "File Storage API", description = "Upload and manage files.")
public interface FileStorageOperation {
	
	@ApiMethod(path = "/api/file/store/{start}/{end}", verb = ApiVerb.GET, description = "Upload a file in a folder.")
	@ApiHeaders(headers = {
			@ApiHeader(name = "signature", description = "Authentication signature."),
			@ApiHeader(name = "public-key", description = "Public key of the application.") })
	@ApiResponseObject
	FileStorage store(
			@ApiParam(name = "userName", required = false, description = "User who owns this file. User Name should match one in the user store.", format = "yyyy-MM-dd") String userName, 
			@ApiParam(name = "folder", required = true, description = "Folder where the file will be stored.") String folder, 
			@ApiParam(name = "description", required = true, description = "Description")String description, 
			@ApiParam(name = "tags", required = true, description = "A comma separted list of tags to attach to this file.")String tags, 
			@ApiRequestParam(name="file", defaultValue = "", description="The multi part file to be uploaded.")  MultipartFile file);
	
	FileStorage update(String fileName, String folder, String description,  MultipartFile file);
	
	
	boolean addTags(String fileName, String folder,  String tags);
	boolean removeTags(String fileName, String folder, String tags);
	boolean removeAllTags(String fileName,  String folder);
	
	boolean removeOwner(String fileName, String folder);
	boolean changeOwner(String fileName, String folder, String oldOwner, String newOwner);
	
	
	FileStorage moveFolder(String fileName, String oldFolder, String newFolder);
	
	
	boolean deleteFolder(String folder);
	boolean renameFolder(String oldFolder, String newFolder);
	
	String deleteByUser(String userName);
	String deleteByName(String fileName);
	String deleteAllByUser(String userName);
	String deleteAll();
	
	long countByType(String type);
	long countByUser(String userName);
	long count();
	
	List<FileStorage> findByType(String type, Pageable page);
	List<FileStorage> findByOwner(String userName, Pageable page);
	List<FileStorage> findAll(Pageable page);
	List<FileStorage> findByTags(String tags[], Pageable page);
	
	byte [] download(String fileName);
	
	FileStorage findByName(String fileName, Pageable page);
	
	
}
